package com.zimin.cloud.web.routers;

import com.zimin.cloud.web.handler.TestHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

@Configuration
public class TestRouters {

    @Bean
    RouterFunction<ServerResponse> userRouter(TestHandler testHandler){
        /**
            RequestPredicates.path("/test") 相当于是类上面的RequestMapping
            RouterFunctions.route(RequestPredicates.GET("/1")  相当于是方法上的GetMapping
            handler:test 就是相对应的方法了
         */
        return RouterFunctions.nest(RequestPredicates.path("/test"),
                RouterFunctions.route(RequestPredicates.GET("/1"),testHandler::test));
    }

}
